<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户管理</title>
<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
  <script type="text/javascript" th:src="@{/js/jquery-1.12.4.js}"></script>
<script type="text/javascript">
function tipOpen(content) {
	$(".tipright p").text(content);
	$("#tip").fadeIn(200);
}
function tipClose() {
	$("#tip").fadeOut(200);
}
</script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>客户浏览</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form id="form" action="/erp/market/customerBrowse/findPageAll" method="post">
    <input type="hidden" id="pageNum" name="pageNum"/>
    <ul class="tools">
      <li> 公司名称:
        <input placeholder="请输入名称" type="text" size="12" name="company" th:value="${custom==null?'':custom.company}"/>
      </li>
      <li> 客户姓名:
        <input placeholder="请输入姓名" type="text" size="12" name="customname" th:value="${custom==null?'':custom.customname}"/>
      </li>
      <li> 所属区域：
        <select name="pid">
          <option value="0">请选择省份</option>
          <option th:each="p : ${provinceList}" th:selected="${pid==p.id}" th:value="${p.id}"
                  th:text="${p.pName}">北京
          </option>
        </select>
        <input type="hidden" th:value="${cid}" name="cid"/>
        <select name="address">
          <option value="0">请选择城市</option>
        </select>
      </li>
      <script>
        $(function () {
          ajaxCid($("select[name=pid]").val());

          $("select[name=pid]").change(function () {
            ajaxCid($(this).val());
          });
        });

        function ajaxCid(pid) {
          $.ajax({
            url: "/erp/market/customer/ajaxCityPid",
            data: {"pid": pid},
            dataType: "JSON",
            success: function (data) {
              var op = "<option value='0'>请选择城市</option>";
              $.each(data, function (i, e) {
                if (e.id == $("input[name=cid]").val()) {
                  op += "<option value='" + e.id + "' selected>" + e.cname + "</option>";
                } else {
                  op += "<option value='" + e.id + "'>" + e.cname + "</option>";
                }
              });
              $("select[name=address]").html("");
              $("select[name=address]").append(op);

            }, error: function () {
              console.log("错误");
            }
          });
        }
      </script>
      <li class="subBut" onclick="tiaoZhuan(1)"><img th:src="@{/images/t06.png}" />查询</li>
      <li class="subBut" onclick="qingkong()"><img th:src="@{/images/t03.png}"/>重置</li>
      <script>
        function qingkong() {
          $("input[name=company]").val("");
          $("input[name=customname]").val("");
          $("select[name=pid]>option:eq(0)").prop("selected",true);
          $("input[name=cid]").val("");
          ajaxCid($("select[name=pid]").val());
        }
      </script>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>客户姓名</th>
          <th>性别</th>
          <th>联系电话</th>
          <th>所属公司</th>
          <th>所属区域</th>
          <th>分配时间</th>
          <th>客服人员</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr th:each="c,i :${pb.list}">
          <td th:text="${(pb.pageNum-1)*pb.pageSize+i.count}">1</td>
          <td th:text="${c.customname}">王金平</td>
          <td th:text="${c.sex==1?'女':'男'}">男</td>
          <td th:text="${c.telephone}">17370899727</td>
          <td th:text="${c.company}">阿里巴巴</td>
          <td th:text="${c.address==null?'':c.city.province.pName+' '+c.city.cName}">江苏南京</td>
          <td th:text="${c.distractime}"></td>
          <td th:text="${c.serviceid==0?'':c.serviceUser.uname}"></td>
          <td>
            <a th:href="@{'/market/customer/findBy?id='+${c.customid}}" class="tablelink">查看详情</a>
          </td>
        </tr>
      </tbody>
    </table>
    <div class="pagin">
      <div class="message">共<i class="blue" th:text="${pb.total}">1256</i>条记录，当前显示第&nbsp;<i class="blue"
                                                                                            th:text="${pb.pageNum}">2&nbsp;</i>页
      </div>
      <ul class="paginList">
        <li class="paginItem">
          <a href="javascript:void(0);" th:onclick="tiaoZhuan([[${pb.isFirstPage?1:pb.pageNum-1}]])">
            <span th:class="${pb.isFirstPage?'pagepre':'pagenxt roate'}"></span>
          </a>
        </li>

        <li class="paginItem" th:if="${1+4<=pb.pageNum}"><a th:onclick="tiaoZhuan(1)"
                                                            href="javascript:void(0);">1</a></li>
        <li class="paginItem more" th:if="${1+5<=pb.pageNum}"><a href="javascript:void(0);">...</a></li>
        <li class="paginItem" th:if="${1+3<=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum-3}]])"
                                                            href="javascript:void(0);"
                                                            th:text="${pb.pageNum-3}">3</a></li>
        <li class="paginItem" th:if="${1+2<=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum-2}]])"
                                                            href="javascript:void(0);"
                                                            th:text="${pb.pageNum-2}">4</a></li>
        <li class="paginItem" th:if="${1+1<=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum-1}]])"
                                                            href="javascript:void(0);"
                                                            th:text="${pb.pageNum-1}">1</a></li>

        <li class="paginItem current"><a href="javascript:void(0);" th:text="${pb.pageNum}">2</a></li>

        <li class="paginItem" th:if="${pb.pages-1>=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum+1}]])"
                                                                   href="javascript:void(0);"
                                                                   th:text="${pb.pageNum+1}">3</a></li>
        <li class="paginItem" th:if="${pb.pages-2>=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum+2}]])"
                                                                   href="javascript:void(0);"
                                                                   th:text="${pb.pageNum+2}">4</a></li>
        <li class="paginItem" th:if="${pb.pages-3>=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pageNum+3}]])"
                                                                   href="javascript:void(0);"
                                                                   th:text="${pb.pageNum+3}">5</a></li>
        <li class="paginItem more" th:if="${pb.pages-5>=pb.pageNum}"><a href="javascript:void(0);">...</a></li>
        <li class="paginItem" th:if="${pb.pages-4>=pb.pageNum}"><a th:onclick="tiaoZhuan([[${pb.pages}]])"
                                                                   href="javascript:void(0);"
                                                                   th:text="${pb.pages}">10</a></li>

        <li class="paginItem">
          <a href="javascript:void(0);" th:onclick="tiaoZhuan([[${pb.isLastPage?pb.pages:pb.pageNum+1}]])">
            <span th:class="${pb.isLastPage?'pagepre roate ':'pagenxt '}"></span>
          </a>
        </li>
      </ul>
    </div>
  </form>
  <script>
    function tiaoZhuan(pageNum) {
      $("#pageNum").val(pageNum);
      $("#form").submit();
    }
  </script>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
